<?php
/**
 * Author: Dcr
 * Date: 2019/7/19
 * Time: 8:45
 */
namespace dcr;
defined('IN_DCR') or exit('No permission resources.');
use dcr\classes\PdoClass;
class Model
{
    public $db;
    protected $config;
    public function __construct($config=[])
    {
        $this->config = $config;
        $this->db = $this->connect();
    }

    /**
     * 连接数据库
     * @return PdoClass|null
     * @throws \Exception
     */
    function connect(){
        $config = $this->config;
        if( empty($config) ){
            //获取数据库配置信息
            $config = Base::getConfig('db');
        }
        //连接数据库
        $db = PdoClass::getInstance($config);
        return $db;
    }

}